package com.cusc.module_login.utils;

import androidx.core.content.ContextCompat;

import com.cusc.lib_api.bean.login.MainBean;
import com.cusc.lib_api.bean.login.response.LoginInfoBean;
import com.cusc.lib_api.config.ModulePermissionModel;
import com.cusc.module_login.R;
import com.tcgroup.phone.base_core.BaseApplication;
import com.tcgroup.phone.base_core.store.MmkvStore;
import com.tcgroup.phone.base_core.store.StoreKey;

import java.util.ArrayList;
import java.util.List;

/**
 * 作者: wangfei
 * 创建时期: 2020/3/26.
 * 包名: com.cusc.module_login.utils
 * 类名: OSAndroidMvvm
 */
public class ModulePermission {

    public static void modulePermissionByGWC(LoginInfoBean mLoginInfoBean,ArrayList<MainBean> mMainBeanArrayList) {
        List<String> userRoleBeans = mLoginInfoBean.getUserRole().get(0).getModuleList();
        if (userRoleBeans.contains(ModulePermissionModel.FunctionModule.JKZX)){
            MainBean bean = new MainBean(R.drawable.main_monitor,"监控中心","",0);
            mMainBeanArrayList.add(bean);
        }
        if (userRoleBeans.contains(ModulePermissionModel.FunctionModule.SPJK)){
            MainBean bean = new MainBean(R.drawable.main_video_monitor,"视频监控","",0);
            mMainBeanArrayList.add(bean);
        }
        if (userRoleBeans.contains(ModulePermissionModel.FunctionModule.YCSQ)){
            MainBean bean = new MainBean(R.drawable.main_apply,"用车申请","",0);
            mMainBeanArrayList.add(bean);
        }
        if (userRoleBeans.contains(ModulePermissionModel.FunctionModule.YCSP)){
            MainBean bean = new MainBean(R.drawable.main_approval,"用车审批","",0);
            mMainBeanArrayList.add(bean);
        }
        if (userRoleBeans.contains(ModulePermissionModel.FunctionModule.YCDD)){
            MainBean bean = new MainBean(R.drawable.main_dispatch,"用车调度","",0);
            mMainBeanArrayList.add(bean);
        }
        if (userRoleBeans.contains(ModulePermissionModel.FunctionModule.SJCC)){
            MainBean bean = new MainBean(R.drawable.main_order,"司机出车","",0);
            mMainBeanArrayList.add(bean);
        }
        if (userRoleBeans.contains(ModulePermissionModel.FunctionModule.GDQR)){
            MainBean bean = new MainBean(R.drawable.main_confirmbacktrace,"归队确认","",0);
            mMainBeanArrayList.add(bean);
        }
        if (userRoleBeans.contains(ModulePermissionModel.FunctionModule.YCPJ)){
            MainBean bean = new MainBean(R.drawable.main_comment,"用车评价","",0);
            mMainBeanArrayList.add(bean);
        }
        if (userRoleBeans.contains(ModulePermissionModel.FunctionModule.YXTJ)){
            MainBean bean = new MainBean(R.drawable.main_statistics_run,"运行统计","",0);
            mMainBeanArrayList.add(bean);
        }
        if (userRoleBeans.contains(ModulePermissionModel.FunctionModule.CBTJ)){
            MainBean bean = new MainBean(R.drawable.main_statistics_cost,"成本统计","",0);
            mMainBeanArrayList.add(bean);
        }

        for (int index = 0; index < mMainBeanArrayList.size(); index++) {
            if (index % 4 == 0 || index % 4 == 3) {
                mMainBeanArrayList.get(index).setModelBackGround(ContextCompat.getColor(BaseApplication.getInstance(),R.color.transparent50_blue));
            }else if (index % 4 == 1 || index % 4 == 2) {
                mMainBeanArrayList.get(index).setModelBackGround(ContextCompat.getColor(BaseApplication.getInstance(),R.color.transparent80_blue));
            }
        }

        MmkvStore.getInstance().saveListInfo(StoreKey.Module_Login.Module_List_01,mMainBeanArrayList);
    }
}
